#pragma once
#include "mkvparserstream.hpp"

namespace MkvParser
{

class AudioTrack;
class AudioStream : public Stream
{
    explicit AudioStream(AudioTrack*);
    AudioStream(const AudioStream&);
    AudioStream& operator=(const AudioStream&);
    
public:
    static AudioStream* CreateInstance(AudioTrack*);
    
    void GetMediaTypes(CMediaTypes&) const;
    HRESULT QueryAccept(const AM_MEDIA_TYPE*) const;

    HRESULT SetConnectionMediaType(const AM_MEDIA_TYPE&);
    HRESULT UpdateAllocatorProperties(ALLOCATOR_PROPERTIES&) const;
    
    long GetBufferSize() const;

protected:
    std::wostream& GetKind(std::wostream&) const;
    HRESULT OnPopulateSample(const BlockEntry* pNext, IMediaSample* pSample);

    void GetAc3MediaTypes(CMediaTypes&) const;
    void GetVorbisMediaTypes(CMediaTypes&) const;
    void GetMp3MediaTypes(CMediaTypes&) const;
    
    bool SendPreroll(IMediaSample*);
        
    bool (AudioStream::*m_preroll)(IMediaSample*);
    bool DoNothing(IMediaSample*);
    bool SendOggIdentPacket(IMediaSample*);    
    bool SendOggCommentPacket(IMediaSample*);
    bool SendOggSetupPacket(IMediaSample*);

    BYTE GetChannels() const;
    ULONG GetSamplesPerSec() const;
    BYTE GetBitsPerSample() const;

};


}  //end namespace MkvParser
